-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make pacledt-compose'Node' #9
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
とりあえずこれだけ
あと今入ってる日本語のコメント全部消してください
packet/packet_composed/include/packet_composed/sensorspacket.hpp
Outdated
Show resolved
Hide resolved
packet/packet_composed/include/packet_composed/sensorspacket.hpp
Outdated
Show resolved
Hide resolved
packet/packet_composed/include/packet_composed/sensorspacket.hpp
Outdated
Show resolved
Hide resolved
…とをしている気がします。ご指摘いただきたいです。よろしくお願いいたします。
slackでお騒がせしてすみません。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
作成するnodeは一つだけでいいです
欲しいのは"複数のtopicをsubscribeして一つのtopicにまとめるnode"なので, 以下のようなクラス定義が与えられます
class Composed : public rclcpp::Node {
private:
rclcpp::Publisher<packet_interfaces::msg::Composed>::SharedPtr composed_publisher;
rclcpp::Subscription<packet_interfaces::msg::Depth>::SharedPtr depth_subscription;
rclcpp::Subscription<sensor_msgs::msg::Imu>::SharedPtr imu_subscription;
rclcpp::Subscription<packet_interfaces::msg::Flex>::SharedPtr flex1_subscription;
rclcpp::Subscription<packet_interfaces::msg::Flex>::SharedPtr flex2_subscription;
// current, voltageのsubscriptionは略
void depth_topic_callback(const packet_interfaces::msg::Depth& msg);
void imu_topic_callback(const sensor_msgs::msg::Imu& msg);
void flex1_topic_callback(const packet_interfaces::msg::Flex& msg);
void flex2_topic_callback(const packet_interfaces::msg::Flex& msg);
// current, voltageのcallbackは略
// さらにいくつかのメソッド, プロパティが必要になる
public:
Composed();
};
より具体的には, "subscribeしたtopicの内容を記憶し, それらを組み合わせたtopicを定期的にpublishする"といったnodeになると思います.
今、コメントを読んでコードを変更しているところです。 私がやる方向性として このことを理解してpacket_composed/src内にあるcompsed.cppとcomposed_main.cpp、CMakeLists.txt、package.xmlt, ということは、この前私がPRを出したときにdepthなどの複数のノードを作成したパッケージは削除して、一番最初に作成したcomposedのファイルだけ残せばよいのでしょうか? ちなみにまだ、ファイルを一切消していません。。 よろしくお願いいたします。 |
あってる!Flexは2つあるので注意してください。
あってる!!他のやつはバッサリ捨てちゃってください 🔥 |
ありがとうございます!!! |
#3 色々と調べて、Composedクラスがセンサーデータ(Depth、IMU、Flexなど)を受信し、それらを1つのComposedメッセージとしてまとめてパブリッシュする。 [自分がした大まかな手順] このノードでやりたいことはわかるのですが、、 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
やりたいのは「複数topicを受信して、 一つの topicにまとめて 同時に publishする」ということです。今のコードだと「一つのtopicにまとめる」ところはできてますが、「同時にpublishする」というのができていません。これを実現するためには、以下のようにする必要があります。
- subscriptionで受信したtopicを一度保存する
- タイマー機能で、保存されているtopicを一つにまとめてpublishする
この「一度保存する」というのをどう実現するかが少し難しいところですが、考えて見てください。(しばらく考えてわかんなかったら教えてください)
packet/packet_composed/include/packet_composed/sensorspacket.hpp
Outdated
Show resolved
Hide resolved
packet/packet_composed/include/packet_composed/sensorspacket.hpp
Outdated
Show resolved
Hide resolved
一旦、上記のコメント読んで直したファイルをcommit→PR出しました。 「同時にpublishする」という部分については考え中です。 個人的に浮かんだ考え方はcomposed.cppのcomposedのループを利用すればいいと思っています。
この部分にif文を追加して、同時に受け取ったときpublishするというif文を作る。 |
あってる。
subscriptionのcallbackとtimerのcallbackは非同期に呼ばれるので、「同時に受け取った時」を判定するのはとても難しそうです。
良さそうだけど、関数ではなく状態、ないしメンバ変数かな |
今の状況として、、やってみたことは以下の通りです。 composed.cppのcomposedのループを利用してみた。
subscriptionのcallbackとtimerのcallbackは非同期に呼ばれるので、「同時に受け取った時」を判定できないので、どうしたら、タイマー機能で、保存されているtopicを一つにまとめてpublishすることができるのか悩んでいます。。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
かなり良くなってきました 👍
日本語コメントとコメントアウトした部分は全部いらないので消しちゃってください
遅くなってしまいすみません。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
これだけかなー
packet/packet_composed/package.xml
Outdated
<depend>packet_interfaces</depend> | ||
<depend>packet_interfaces</depend> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<depend>packet_interfaces</depend> | |
<depend>packet_interfaces</depend> | |
<depend>packet_interfaces</depend> |
rclcpp::Subscription<packet_interfaces::msg::Voltage>::SharedPtr voltage_subscription; | ||
|
||
rclcpp::TimerBase::SharedPtr _timer; | ||
size_t _count; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_count
消えてないです
size_t _count; |
#3